#include <cstdio>
#include <vector>

int main() {
    int n;
    scanf("%d", &n);
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }
    const int SQRT = 1000;
    std::vector<int> count1(1 + SQRT);
    std::vector<long long> count2(1 + SQRT);
    const int MAX = SQRT * SQRT;
    std::vector<int> count1mul(1 + MAX);
    std::vector<long long> count2mul(1 + MAX);
    long long sum2 = 0;
    for (int i = n - 1; i >= 0; i--) {
        int v = a[i];

        for (int d = 1; d <= SQRT && d <= v; d++) {
            if (v % d == 0) {
                sum2 += count2[d];
            }
        }
        if (v > SQRT) {
            sum2 += count2mul[v];
        }

        int sum1 = 0;
        for (int d = 1; d <= SQRT && d <= v; d++) {
            if (v % d == 0) {
                sum1 += count1[d];
            }
        }
        if (v > SQRT) {
            sum1 += count1mul[v];
        }

        if (v <= SQRT) {
            count1[v]++;
        } else {
            for (int mv = v; mv <= MAX; mv += v) {
                count1mul[mv]++;
            }
        }

        if (v <= SQRT) {
            count2[v] += sum1;
        } else {
            for (int mv = v; mv <= MAX; mv += v) {
                count2mul[mv] += sum1;
            }
        }
    }

    printf("%lld", sum2);

    return 0;
}
